package com.djh.security.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore;

/**
 * TokenStore配置类
 *
 * @author qipp
 * @date 2020/1/10 16:25
 * @since 1.0.1
 */
@Slf4j
@ConditionalOnBean(ResourceServerConfig.class)
public class TokenStoreConfig {

    /**
     * redis
     */
    private final RedisConnectionFactory redisConnectionFactory;

    public TokenStoreConfig(RedisConnectionFactory redisConnectionFactory) {
        this.redisConnectionFactory = redisConnectionFactory;
    }


    @Bean
    public RedisTokenStore redisTokenStore(){
        log.info("使用  --->  RedisTokenStore 存储token");
        return new RedisTokenStore(redisConnectionFactory);
    }
}
